<script setup lang="ts">
import {store} from '../../common/store.ts';

import {useUserStore} from "@/common/setup_store.ts";

const userStore = useUserStore();

function add() {
  userStore.increment();//调用方法
  // userStore.$patch({count: userStore.count + 1});//触发一个事件，并提交参数
}

</script>

<template>
  <el-card class="mb-4">
    <template #header>
      <div class="card-header">状态管理</div>
    </template>
    点击数： {{ store.count }}

    <el-button type="primary" @click="store.count++">点击</el-button>
    <el-button type="success" @click="store.increment()"> increment</el-button>

    <template #footer>
      footer
    </template>
  </el-card>

  <el-card>
    <template #header>
      <div class="card-header">组合式API函数定义pinia</div>
    </template>
    <el-button type="success" @click="add">点击数{{ userStore.count }}</el-button>
  </el-card>

</template>

<style scoped>

</style>